Skip to content

fix: Use var.typeStr metadata for type coercion in _caput#872

Open
ruck314 wants to merge 1 commit intomainfrom
issues-853-clean
Open

fix: Use var.typeStr metadata for type coercion in _caput#872
ruck314 wants to merge 1 commit intomainfrom
issues-853-clean

Conversation

@ruck314
Copy link
Copy Markdown
Contributor

@ruck314 ruck314 commented Apr 3, 2026

Summary

  • Extracts a coerce_value_for_var(var, val) helper in tools.py that uses var.typeStr metadata to determine expected types, replacing the var.value() read-based type discovery in _caput
  • Adds a static TYPEMAP dict mapping all 12 standard Rogue 6 typeStr values to Python/numpy types
  • Replaces 4 deprecated np.uint call sites in smurf_command.py with np.uint64

Test plan

  • flake8 --count python/ passes with zero errors
  • Existing CI test suite passes with no regressions
  • Verify _caput enum branch (var.enum is not None) and command branch (var.isCommand) are unchanged

Closes #853

…var.value()

Extract a reusable coerce_value_for_var helper that uses rogue variable
metadata (typeStr) to determine expected types, replacing the var.value()
read-based type discovery. Also replaces deprecated np.uint calls with
np.uint64.

Closes #853
@ruck314 ruck314 requested review from swh76 and tristpinsm as code owners April 3, 2026 06:12
@github-actions github-actions bot added the client Changes to the client code label Apr 3, 2026
@tristpinsm
Copy link
Copy Markdown
Collaborator

tristpinsm commented Apr 3, 2026

The list of typeStr doesn't account for every possible type. At minimum, those explicitly defined in cryo-det include:

$ grep -rn "typeStr" firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoFreqBand.py:227:            typeStr      = "UInt6",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoFreqBand.py:588:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoFreqBand.py:715:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannel.py:44:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannel.py:53:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannel.py:62:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannel.py:71:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannel.py:81:            typeStr      = "UInt1",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannel.py:90:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannel.py:99:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannel.py:109:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannel.py:118:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannel.py:128:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannel.py:139:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannels.py:191:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannels.py:200:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannels.py:210:            typeStr      = "Float64",
firmware/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_CryoChannels.py:220:            typeStr      = "Float64",

UInt1, UInt6, Float64 are missing, not sure if there could be arbitrarily more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client Changes to the client code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rogue 6: Handle type checking more reliably

2 participants